using System;
using FytSoa.Common.Utils;
using System.ComponentModel.DataAnnotations;
using FytSoa.Application.Crm;
using FytSoa.Application.Hr;
using FytSoa.Common.Enum;
using Masuit.Tools.Systems;
using SqlSugar;

namespace FytSoa.Application.Erp;

/// <summary>
/// erp-产品出库
/// </summary>
public class ErpOutstockDto : AppEntity
{
    /// <summary>
    /// 出库编号
    /// </summary>
    [Required]
    [StringLength(50)]
    public string Number { get; set; }

    /// <summary>
    /// 1=销售2=生产3=采购4=其他
    /// </summary>
    [Required]
    public ErpOutStockTypeEnum Type { get; set; } = ErpOutStockTypeEnum.Sales;
    
    /// <summary>
    /// 1=销售2=生产3=采购4=其他
    /// </summary>
    public string TypeName => Type.GetDescription();
    
    /// <summary>
    /// 单位编号
    /// </summary>
    [Required]
    public long CustomerId { get; set; }
    
    /// <summary>
    /// 公司信息
    /// </summary>
    public CrmCustomerSimpleDto Customer { get; set; }
    
    /// <summary>
    /// 部门编号
    /// </summary>
    [Required]
    public long DepartmentId { get; set; }
    
    /// <summary>
    /// 部门信息
    /// </summary>
    public HrOrganizationSimple Organization { get; set; }

    /// <summary>
    /// 关系编号(销售/采购)
    /// </summary>
    [Required]
    public long RelationId { get; set; }
    
    /// <summary>
    /// 生产对应的申请物料编号
    /// </summary>
    [Required]
    public long ApplyId { get; set; } = 0;

    public ErpPurchaseApplySimpleDto Apply { get; set; }
    
    /// <summary>
    /// 关系内容
    /// </summary>
    public ErpOutStockRelationDto Relation { get; set; } = new ();

    /// <summary>
    /// 仓库编号
    /// </summary>
    [Required]
    public long WarehouseId { get; set; }

    /// <summary>
    /// 仓库信息
    /// </summary>
    public ErpWarehouseSimpleDto Warehouse { get; set; } = new();

    /// <summary>
    /// 出库时间
    /// </summary>
    [Required]
    public DateTime OutStockTime { get; set; } = DateTime.Now;
    
    /// <summary>
    /// 产品集合编号
    /// </summary>
    public List<long> ProductIds { get; set; } = new();
    
    /// <summary>
    /// 审核状态
    /// </summary>
    public ErpAuditEnum Status { get; set; } = 0;
    
    /// <summary>
    /// 审批流程
    /// </summary>
    [Required]
    public long FlowId { get; set; } = 0;

    /// <summary>
    /// 审批流程详情
    /// </summary>
    [Required]
    public ErpFlowDto.ErpFlowSimpleDto Flow { get; set; } = new();

    /// <summary>
    /// 备注
    /// </summary>
    public string Remark { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }


}

/// <summary>
/// 关系对象
/// </summary>
public class ErpOutStockRelationDto
{
    public long Id { get; set; }

    public string Number { get; set; }
}